package com.mateng.treasurechest.model.recipe.bean

import org.json.JSONArray
import org.json.JSONException
import java.util.*

/**
 * Created by mateng on 2018/1/27.
 */

class RecipeDetailsBean : BaseModel() {


    /**
     * msg : success
     * result : {"ctgIds":["0010001007","0010001025"],"ctgTitles":"荤菜,煮","menuId":"00100010070000017754","name":"椒麻鸡凉菜","recipe":{"img":"http://f2.mob.com/null/2015/08/19/1439946000389.jpg","ingredients":"[\"子公鸡半只（约一斤半）、鲜花椒约十五粒、花椒油一咖啡匙、酱油四大匙、老姜一块，拍破、香葱半两切长段，留一棵待用、香油一大匙、盐、味精适量。\"]","method":"[{\"img\":\"http://f2.mob.com/null/2015/08/19/1439946000698.jpg\",\"step\":\"1.将鸡整理干净后放入温水锅，下姜、葱段、盐，加盖用大火烧沸后改小火煮十五至二十分钟（视鸡的品种和老嫩而定），把锅端离火炉，让鸡在汤里浸泡约十分钟。\"},{\"img\":\"http://f2.mob.com/null/2015/08/19/1439946000901.jpg\",\"step\":\"2.将鲜花椒、留下的一棵葱、微量盐、半咖啡匙香油放菜板上剁成细末。\"},{\"img\":\"http://f2.mob.com/null/2015/08/19/1439946001241.jpg\",\"step\":\"3.盛小碗里，加入酱油、味精、香油、花椒油拌成味料。\"},{\"step\":\"4.将鸡取出晾凉，斩成条后整齐地码在盘子里。浇上味料即可上桌。\"}]","sumary":"椒麻鸡属于清爽凉菜，主要原料是鸡肉，口味是咸香，工艺是煮，难度属于中级。","title":"怎样做椒麻鸡凉菜"},"thumbnail":"http://f2.mob.com/null/2015/08/19/1439945968897.jpg"}
     * retCode : 200
     */

    var result: ResultBean? = null

    class ResultBean {
        /**
         * ctgIds : ["0010001007","0010001025"]
         * ctgTitles : 荤菜,煮
         * menuId : 00100010070000017754
         * name : 椒麻鸡凉菜
         * recipe : {"img":"http://f2.mob.com/null/2015/08/19/1439946000389.jpg","ingredients":"[\"子公鸡半只（约一斤半）、鲜花椒约十五粒、花椒油一咖啡匙、酱油四大匙、老姜一块，拍破、香葱半两切长段，留一棵待用、香油一大匙、盐、味精适量。\"]","method":"[{\"img\":\"http://f2.mob.com/null/2015/08/19/1439946000698.jpg\",\"step\":\"1.将鸡整理干净后放入温水锅，下姜、葱段、盐，加盖用大火烧沸后改小火煮十五至二十分钟（视鸡的品种和老嫩而定），把锅端离火炉，让鸡在汤里浸泡约十分钟。\"},{\"img\":\"http://f2.mob.com/null/2015/08/19/1439946000901.jpg\",\"step\":\"2.将鲜花椒、留下的一棵葱、微量盐、半咖啡匙香油放菜板上剁成细末。\"},{\"img\":\"http://f2.mob.com/null/2015/08/19/1439946001241.jpg\",\"step\":\"3.盛小碗里，加入酱油、味精、香油、花椒油拌成味料。\"},{\"step\":\"4.将鸡取出晾凉，斩成条后整齐地码在盘子里。浇上味料即可上桌。\"}]","sumary":"椒麻鸡属于清爽凉菜，主要原料是鸡肉，口味是咸香，工艺是煮，难度属于中级。","title":"怎样做椒麻鸡凉菜"}
         * thumbnail : http://f2.mob.com/null/2015/08/19/1439945968897.jpg
         */

        var ctgTitles: String? = null
        var menuId: String? = null
        var name: String? = null
        var recipe: RecipeBean? = null
        var thumbnail: String? = null
        var ctgIds: List<String>? = null

        class RecipeBean {
            /**
             * img : http://f2.mob.com/null/2015/08/19/1439946000389.jpg
             * ingredients : ["子公鸡半只（约一斤半）、鲜花椒约十五粒、花椒油一咖啡匙、酱油四大匙、老姜一块，拍破、香葱半两切长段，留一棵待用、香油一大匙、盐、味精适量。"]
             * method : [{"img":"http://f2.mob.com/null/2015/08/19/1439946000698.jpg","step":"1.将鸡整理干净后放入温水锅，下姜、葱段、盐，加盖用大火烧沸后改小火煮十五至二十分钟（视鸡的品种和老嫩而定），把锅端离火炉，让鸡在汤里浸泡约十分钟。"},{"img":"http://f2.mob.com/null/2015/08/19/1439946000901.jpg","step":"2.将鲜花椒、留下的一棵葱、微量盐、半咖啡匙香油放菜板上剁成细末。"},{"img":"http://f2.mob.com/null/2015/08/19/1439946001241.jpg","step":"3.盛小碗里，加入酱油、味精、香油、花椒油拌成味料。"},{"step":"4.将鸡取出晾凉，斩成条后整齐地码在盘子里。浇上味料即可上桌。"}]
             * sumary : 椒麻鸡属于清爽凉菜，主要原料是鸡肉，口味是咸香，工艺是煮，难度属于中级。
             * title : 怎样做椒麻鸡凉菜
             */

            var img: String? = null
            private var ingredients: String? = null
            var method: String? = null
            var sumary: String? = null
            var title: String? = null

            fun getIngredients(): List<String>? {
                try {
                    val array = JSONArray(ingredients)
                    return (0 until array.length()).mapTo(ArrayList()) { array.getString(it) }
                } catch (e: JSONException) {
                    e.printStackTrace()
                }
                return null
            }

            fun setIngredients(ingredients: String) {
                this.ingredients = ingredients
            }
        }
    }
}
